package com.hc.radius.command;

import java.util.List;

import com.hc.radius.service.Const;
import com.hc.util.Util;

public class LoginCommand extends Command {

	
	public LoginCommand() {
		 servicename = Const.MSG_SERVICE_NAME_SRVM;
		 sessionCtrl = Const.MSG_DLGLGN;
	}

	@Override
	public int getLen(CommandParam cmdp) {
		int len = 56 + Const.CMD_LOGIN.length + Const.CMD_PASWD.length;
		len += Util.getLen(cmdp.name,cmdp.pswd) + 4;
		return len;
	}

	@Override
	public void addCmdContent(List<Byte> list, CommandParam cmdp) {
		int len = Const.CMD_LOGIN.length + Const.CMD_PASWD.length;
		CommandWrap.addByte(list,Const.CMD_LOGIN);
		List<Byte> temp =  Util.toByte(Util.toHexString(cmdp.name));
		len += temp.size();
		list.addAll(temp);
		CommandWrap.addByte(list,Const.CMD_PASWD);
		temp =  Util.toByte( Util.toHexString(cmdp.pswd));
		len += temp.size();
		list.addAll(temp);
		CommandWrap.addTail(list, len);		
	}
	 
}
